﻿var colType = {
    string: 0,
    int: 1,
    decimal: 2,
    datetime: 3,

};


(function ($) {
    $.Export = function (parm) {

        $.AjaxRequest('ImportingAndExporting_WPSExporting', parm, function (data) {
            window.open(data);
        });
    }
    $.Import = function (parm) {
        $.AjaxRequest('ImportingAndExporting_WPSImporting', parm, function () {


        });
    }

    $.fn.Export = function (parm) {
        var grid = $(this);
        var dataconfig = [];

        $("thead tr", grid).each(function (i) {
            $("th", $(this)).each(function (j) {
                var th = $(this);
                dataconfig.push({ Name: th.text(), RowSpan: th.attr('rowspan'), ColSpan: th.attr('colspan'), RowNum: i });
            })
        });
        var data = [];
        $('tbody tr', grid).each(function () {
            var row = [];
            $("td", $(this)).each(function () {
                var td = $(this);
                row.push({ Value: td.text(), RowSpan: td.attr('rowspan'), ColSpan: td.attr('colspan') });
            });
            data.push(row)
        });
        if (!parm.List) {
            parm.List = [];
            parm.List.push({
                Data: data,
                Config: dataconfig
            });
        }
        else {
            parm.List[0].Data = data;
            parm.List[0].Config = dataconfig;

        }

        $.Export(parm);
    }

})(jQuery)

